package cn.agiledata.bank.common.tag;

import java.util.Iterator;
import java.util.List;

import javax.servlet.jsp.JspException;
import javax.servlet.jsp.tagext.BodyTagSupport;

import org.apache.struts.taglib.TagUtils;

import cn.agiledata.bank.common.servlet.InitForString;
import cn.agiledata.bank.hibernateBean.ActionType;
import cn.agiledata.bank.hibernateBean.Sysbook;

public class StatusChange extends BodyTagSupport {
	private String typeId;

	public String getTypeId() {
		return typeId;
	}

	public void setTypeId(String typeId) {
		this.typeId = typeId;
	}

	public int doEndTag() throws JspException {
		// TODO Auto-generated method stub
		List typeList = (List) InitForString.dataDictMap.get(this.getTypeId());
		Iterator typeIter = typeList.iterator();
		String typeId = this.getBodyContent().getString();
		while(typeIter.hasNext()){
			Object obj = typeIter.next();
			if (obj instanceof Sysbook){
				Sysbook sys = (Sysbook)obj;
				if (typeId.trim().equals(sys.getId().getListId())){
					TagUtils.getInstance().write(this.pageContext,sys.getListName());
					break;
				}
			}else if (obj instanceof ActionType){
				ActionType at = (ActionType)obj;
				if (typeId.trim().equals(at.getId().toString())){
					TagUtils.getInstance().write(this.pageContext,at.getActionName());
					break;
				}
			}
		}
		return super.doEndTag();
	}
	
}
